/**
 * 系统登录
 */
$(document).ready(function(){
    Login.changeCode();
});
var Login = {};
//改变验证码
Login.changeCode = function()
{
    var o = $('#codeImg'),
        src = o.attr('src'),
        index = src.indexOf('?'),
        img = src.substring(0,index<0?src.length:index),
        rand = Math.random();
    o.attr('src',img+'?'+rand);
}
/**
 * 执行登录
 */
Login.login = function(){
    var name = $('#username').val(),
        pwd = $('#pwd').val(),
        code = $('#code').val(),
        a = $('#alert-box');
    if(name == "") {
        a.html('请输入用户名');
        return false;
    }
    if(pwd == "") {
        a.html('请输入密码');
        return false;
    }
    if(code == ""){
        a.html('请输入验证码');
        return false;
    }
    $('#loginForm').ajaxForm(function(e){
        if(e=='null'){
            window.location.href = APP+'/system/index.html';
        }else{
            a.html(e);
        }
    }).submit();
}